package com.yneusoft.pctask.controller;

import com.yneusoft.common.enums.ResultEnum;
import com.yneusoft.common.model.ResponseWrapper;
import com.yneusoft.pctask.model.StaffLoginParam;
import com.yneusoft.pctask.service.LoginManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @Description： 登录模块controller
 * @Author: wbf
 * @Date: 2021/11/24 10:29
 */
@RestController
@CrossOrigin
@RequestMapping("/loginManage")
public class LoginManageController {
    @Autowired
    private LoginManageService loginManageService;
    /**
     * 1.获取图形验证码
     * @return 图形验证码
     */
    @GetMapping("/getImageCode")
    public ResponseWrapper getImageCode(){
        return loginManageService.getImageCode();
    }

    /**
     * 2、员工登录
     * @return token
     */
    @GetMapping("/staffLogin")
    public ResponseWrapper staffLogin(@Validated StaffLoginParam param){
        return loginManageService.staffLogin(param);
    }

    /**
     * 3、获取所登录员工的名称
     * @return 登录员工的名称
     */
    @GetMapping("/getStaffName")
    public ResponseWrapper getStaffName(){
        return loginManageService.getStaffName();
    }

    /**
     * 4、拦截后的提示信息
     * @return 提示信息
     */
    public static ResponseWrapper backIndex(){
        return ResponseWrapper.markCustom(ResultEnum.FAILED,"登陆异常！请重新登录！");
    }
}
